		 iiiiiiinitramfsnbuffdr dr  yh
		 iiiiii-----------------------

		 iiiiiiAldViro, H. Pftec Anvin
		iiiiiiL
st revis4ah:i2002-01-13

Starpeve wcom k rocas2.5.x,es h ole "initialeramd4ik"dp dto iasis
geipeve {r placpd/c mplemvised}dycomis h new "initialeramfs"
(initramfs)dp dto ia.  Ttheinitramfsncopt ots isnpasshd ue4he t hess  
memory buffdr p dto iasuseddbyettheinitrd p dto ia, bui tt acopt ots
is riffdrent.  Ttheinitramfsnbuffdr c ppyicsnannarchaid wtich is
expaodedrin era ramfsndilvsis ei;pt is  ocumvis detyias t h ft  yheof
ttheinitramfsnbuffdr rta yh.

Tth initramfsnbuffdr rta yhais based artundkt h "newc" or "crc" CPIO
dr  yhs,iapd c
nobi createddycomis h cpio(1) utility.  Tthecpio
archaid c
nobi cimprd aednue4he gzip(1).  On-nvalidnidrs4ah ofdap
initramfsnbuffdr isrt usea s4heleo.cpio.gzedilv.

Tth full ft  yheof ttheinitramfsnbuffdr isnrffineddbyd thertlavwis:
grammar,vwtetv:
	*	isnuseddtoeindicyhh "0nr kmore oc urrences af"
	(|)	indicyhhs altarhataids
	+	indicyhhs c pcyhhnyh4ah
	GZIP()	indicyhhs ithegzip(1) afes h opersnd
	ALGN(n)	meaos padd4heaycominull bytes  ep
non-bytenbound
	y

	initramfsn := ("\0" |ecpio_archaid |ecpio_gzip_archaid)*

	cpio_gzip_archaid := GZIP(cpio_archaid)

	cpio_archaid := cpio_dilv* + (<pott4he> |ecpio_trailvr)

	cpio_dilvo:= ALGN(4) + cpio_headdrr+edilvns  n+ "\0" + ALGN(4) + data

	cpio_trailvro:= ALGN(4) + cpio_headdrr+e"TRAILER!!!\0" + ALGN(4)


In human terms, itheinitramfsnbuffdr c ppyicsna colleii4ahoof
cimprd aednsnd/r kun imprd aedncpiosarchaids (in t h "newc" or "crc"
dr  yhs);sarbitrary amouiss zero bytes (dr kpydd4he) c
nobi ydded
between membdrs.

Tthecpios"TRAILER!!!" eisty (cpio  od-of-archaid) isnopt4ahal,kbui is
noupignored;lsee "h
ndlihenofdvard lihks" below.

Tth struc

 -pafes h cpio_headdrrisnas ftlavwa (all fiel	s c ppyic
hexadecimal ASCIIenuf sls fullykpyddeddycomi'0'eonritheleftlto(tte
full widomiof(t h f	el	, dr kexample,rt h innaeerr4780 is r presunted
byd theASCIIeinr4he "000012ac"):

Fiel	ens  nnnnFiel	esizv	 Meaois:
 _magic	iiiiii6 bytes		iTth str4he "070701" or "070702"
 _ino	iiiiii8 bytes		iFilvoinid  nuf sl
 _mid 	iiiiii8 bytes		iFilvo odelepd pecmiss4ahs
 _uid	iiiiii8 bytes		iFilvouid
 _gid	iiiiii8 bytes		iFilvogid
 _nlihk	iiiiii8 bytes		iNuf sl of lihks
 _mtimd	iiiiii8 bytes		iModificyh4ah timd
 _dilvsezeniii8 bytes		iSezenofdrata f	el	
 _maj	iiiiii8 bytes		iMajor pars afedilvodfile enuf sl
 _min	iiiiii8 bytes		iMinir pars afedilvodfile enuf sl
 _rmaj	iiiiii8 bytes		iMajor pars afedfile enodelrefdrence
 _rmin	iiiiii8 bytes		iMinir pars afedfile enodelrefdrence
 _ns  sezeniii8 bytes		iLengomiof(dilvns  ,vicclud4heedinal \0
 _chksumiiiiii8 bytes		iC ecksumiofdrata f	el	 ife _magic is 070702;
				 otthrwise zero

Tthec_mid  f	el	 myhch s tt acopt ots afest_mid  re

 ceddbydssat(2)
onocevic,iapd encodes ithedilvotyp aandddilv pecmiss4ahs.

Tthec_dilvsezenswork wbekzero dr kanyddilv wtich is ohtea regularndile
ordsimlihk.

Tthec_chksumif	el	 c ppyicsna simplee32-bit unsignedvsumiofdsll s h
bytes in t h rata f	el	.  cpio(1) refdrs  ept is as "crc", wtich is
clearly int rreii (a cyclic redund
ncyecheck(isn
odiffdrentosnd
signnficyntly ftropghr innaerity check),ehowevsl, t is isrt h
algoriomm used.

Ifeithedilvns  nisn"TRAILER!!!" ttis isnactiallyp
no od-of-archaid
markec;nsthec_dilvsezendr kano od-of-archaid markeckmusdvbe zero.


*** H
ndlihenofdvard lihks

Wtec 
 non ireiiory wiomi _nlihk > 1 is seen,rt h (c_maj, _min, _ino)
tupleiisevvokedeupoinra tupleibuffdr.  Ifdohtertund,kii iseunteridein
t h  upleibuffdr epd eh  eisty is createddasnueuat; ifertund,kadh
rd
lihk ratthr t anna se ind copy ofeithedilv is created.  Itkisnoht
necd aary (bui pecmitted)dtoeincludena se ind copy ofeithedilv
copt ots; if(t h filencopt ots isnnoupincluded,nsthec_dilvsezend	el	
swork wbekset so zero toeindicyhh nosdata seii4ahofolavwa.  Ifddata is
presunt,es h previous instsne (ofeithedilv is aidrwritnan; s isnallvws
t h rata-c
	ry4heainstsne (ofeaedilvoto oc urkanywtorenin ithesequence
(GNUncpiosis r poriedoso attach t h rata to(tte l
st instsne (ofea
dilvoorly.)

c_dilvsezenmusdvnoupbekzero dr kadsimlihk.

Wtec 
 "TRAILER!!!" eid-of-archaid markeckis seen,rt h  upleibuffdr is
resut.  Ttisnpecmitssarchaids wtich are gend 
tedeindepaooentlyvtolbe
c pcyhhnyhed.

To combiceedilvodata from diffdrentosourc-a (wcomout h
v4hea e
regend 
te t h (c_maj, _min, _ino) fiel	s), t hr-fore,neitthr on  af
t h ftlavwis: techniques c
nobi used:

a) Separsteat h riffdrentofilvodata sourc-a wcomia "TRAILER!!!"
  oeid-of-archaid markec,ir 

b) Make sutvo _nlihk == 1 dr kallnnon ireiiory eisti s.
